package main

import (
	"context"
	"fmt"
	"time"
)

func main() {


}
func TestCtxChannel()  {
	ctx, cancel := context.WithCancel(context.Background())
	go func() {
		for range time.Tick(time.Second){
			select {
			case <-ctx.Done():
				fmt.Println(ctx.Err())
				fmt.Println("ctx done")
				return
			default:
				fmt.Println("monitor woring",ctx)
			}
		}
	}()
	time.Sleep(3 * time.Second)
	cancel()
	fmt.Println("call cancel Done")

	time.Sleep(3 * time.Second)
}
